{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "import owlready2\n",
    "from owlready2 import *\n",
    "\n",
    "owlready2.JAVA_EXE = '/home/tlw/opt/jdk-8u171-linux-x64/jdk1.8.0_171/bin/java'\n",
    "\n",
    "onto = owlready2.get_ontology(\"http://tlw/learn.owl\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "107\n"
     ]
    }
   ],
   "source": [
    "with onto:\n",
    "    class Person(Thing): pass\n",
    "    class BlackPerson(Person): \n",
    "        def c1():\n",
    "            print('black...')\n",
    "    class WhitePerson(Person): \n",
    "        def c1():\n",
    "            print('white...')\n",
    "\n",
    "trump = WhitePerson()\n",
    "tramp = Person()\n",
    "jordan = BlackPerson()\n",
    "tramp.set_equivalent_to([trump])\n",
    "\n",
    "print(len(onto.get_triples()))\n",
    "onto.save(file='person.ttl', format='turtle')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# close_world(Thing)\n",
    "with onto:\n",
    "    sync_reasoner()\n",
    "\n",
    "print(len(onto.get_triples()))\n",
    "tramp.is_a"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "40d3a090f54c6569ab1632332b64b2c03c39dcf918b08424e98f38b5ae0af88f"
  },
  "kernelspec": {
   "display_name": "Python 3.8.8 ('base')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
